/**********************************************************************************************************
** 驱动文件：	jmkt-EC03U7.c
** 驱动类型：	jmkt
** 设备名称：	精密空调
** 设备型号：	EC03U7
** 设备品牌：	英维克
** 设备协议：	ModbusRTU
** 驱动描述：	适用于英维克EC系列交流空调，通讯协议为03U7-DC03-modbus。
** 生成日期：	2019-12-28 16:06:10
**********************************************************************************************************/
#include "Includes.h"


/**********************************************************************************************************
* 定义设备数据点变量结构
**********************************************************************************************************/
typedef struct{
	Var EquipmentWorkStatus;					//设备工作状态
	Var IndoorFanStatus;						//室内风机状态
	Var OutdoorFanStatus;						//室外风机状态
	Var CompressorStatus;						//压缩机状态
	Var ReturnAirTemperature;					//柜内回风温度
	Var PumpStatus;								//水泵状态
	Var OutsideTemperature;						//柜外温度
	Var CondenserTemperature;					//冷凝器温度
	Var EvaporatorTemperature;					//蒸发器温度
	Var InternalFanSpeed;						//内风机转速
	Var OuterFanSpeed;							//外风机转速
	Var ACInputVoltage;							//交流输入电压
	Var DCInputVoltage;							//直流输入电压
	Var ACRunningCurrent;						//交流运行电流
	Var EquipmentRuntime;						//设备运行时间
	Var CompressorRuntime;						//压缩机运行时间
	Var InternalFanRuntime;						//内风机运行时间
	Var CompressorOperationTimes;				//压缩机动作次数
	Var DCRunningCurrent;						//直流运行电流
	Var DCPower;								//直流功率
	Var ACPower;								//交流功率	
	Var CoolingCapacity;						//制冷量
	Var HighTemperatureAlarm;					//高温报警
	Var InternalFanFailure;						//内风机故障
	Var OuterFanFailure;						//外风机故障
	Var CompressorFailure;						//压缩机故障
	Var ReturnAirTemperatureSensorFailure;		//柜内回风温度探头故障
	Var SystemHighPressureAlarm;				//系统高压告警
	Var LowTemperatureAlarm;					//低温告警
	Var DCOvervoltageAlarm;						//直流过压告警
	Var DCUndervoltageAlarm;					//直流欠压告警
	Var ACOvervoltageAlarm;						//交流过压告警
	Var ACUndervoltageAlarm;					//交流欠压告警
	Var ACPowerFailureAlarm;					//交流掉电告警
	Var EvaporatorTemperatureSensorFailure;		//蒸发器温度传感故障
	Var CondenserTemperatureSensorFailure;		//冷凝器温度传感故障
	Var AmbientTemperatureSensingFailure;		//环境温度传感故障
	Var EvaporatorFreezeAlarm;					//蒸发器冻结报警
	Var FrequentHighPressureAlarm;				//频繁高压力告警
	Var HeatingSensitivity;						//制热精度
	Var DehumidificationSetpoint;				//除湿设定值
	Var DehumidificationSensitivity;			//除湿精度
	Var HumidificationSetpoint;					//加湿设定值
	Var HumidificationSensitivity;				//加湿精度
	Var Circuit1EvaporatingPressure;			//回路1蒸发器压力
	Var Circuit2EvaporatingPressure;			//回路2蒸发器压力
	Var Circuit1SuctionTemperature;				//回路1吸气温度
	Var Circuit2SuctionTemperature;				//回路2吸气温度
	Var Circuit1EvaporatingTemperature;			//回路1蒸发器温度
	Var Circuit2EvaporatingTemperature;			//回路2蒸发器温度
	Var Circuit1Superheat;						//回路1过热度
	Var Circuit2Superheat;						//回路2过热度
	Var ColdWaterValveRamp;						//冷水阀开度
	Var HotWaterValveRamp;						//热水阀开度
	Var EvaporatingFanSpeed;					//蒸发器风扇风速
	Var OnOffStatus;							//开关机状态
	Var AlarmStatus;							//报警状态
}Data_Struct;									//定义变量结构


/**********************************************************************************************************
* 设备数据点变量属性声明
**********************************************************************************************************/
const static Var_Property_Def var_attr[] = {
	{
		OCTSTR,
		0,
		READONLY,
		"EquipmentWorkStatus",
		"设备工作状态",
		"",
		"设备工作状态：0-待机，1-运行，2-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"IndoorFanStatus",
		"室内风机状态",
		"",
		"室内风机状态：0-待机，1-运行，2-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OutdoorFanStatus",
		"室外风机状态",
		"",
		"室外风机状态：0-待机，1-运行，2-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorStatus",
		"压缩机状态",
		"",
		"压缩机状态：0-待机，1-运行，2-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ReturnAirTemperature",
		"柜内回风温度",
		"℃",
		"柜内回风温度",
		0,
		0,
		"柜内回风温度过高",
		"柜内回风温度过低",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"PumpStatus",
		"水泵状态",
		"",
		"水泵状态：0-待机，1-运行，2-故障",
		0,
		0,
		"故障",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"OutsideTemperature",
		"柜外温度",
		"℃",
		"柜外温度",
		0,
		0,
		"柜外温度过高",
		"柜外温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"CondenserTemperature",
		"冷凝器温度",
		"℃",
		"冷凝器温度",
		0,
		0,
		"冷凝器温度过高",
		"冷凝器温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"EvaporatorTemperature",
		"蒸发器温度",
		"℃",
		"蒸发器温度",
		0,
		0,
		"蒸发器温度过高",
		"蒸发器温度过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"InternalFanSpeed",
		"内风机转速",
		"Rpm",
		"内风机转速",
		0,
		0,
		"内风机转速过高",
		"内风机转速过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"OuterFanSpeed",
		"外风机转速",
		"Rpm",
		"外风机转速",
		0,
		0,
		"外风机转速过高",
		"外风机转速过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ACInputVoltage",
		"交流输入电压",
		"V",
		"交流输入电压",
		0,
		0,
		"交流输入电压过高",
		"交流输入电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"DCInputVoltage",
		"直流输入电压",
		"V",
		"直流输入电压",
		0,
		0,
		"直流输入电压过高",
		"直流输入电压过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ACRunningCurrent",
		"交流运行电流",
		"A",
		"交流运行电流",
		0,
		0,
		"交流运行电流过高",
		"交流运行电流过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"EquipmentRuntime",
		"设备运行时间",
		"h",
		"设备运行时间",
		0,
		0,
		"设备运行时间过高",
		"设备运行时间过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"CompressorRuntime",
		"压缩机运行时间",
		"h",
		"压缩机运行时间",
		0,
		0,
		"压缩机运行时间过高",
		"压缩机运行时间过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"InternalFanRuntime",
		"内风机运行时间",
		"h",
		"内风机运行时间",
		0,
		0,
		"内风机运行时间过高",
		"内风机运行时间过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"CompressorOperationTimes",
		"压缩机动作次数",
		"",
		"压缩机动作次数",
		0,
		0,
		"压缩机动作次数过高",
		"压缩机动作次数过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"DCRunningCurrent",
		"直流运行电流",
		"A",
		"直流运行电流",
		0,
		0,
		"直流运行电流过高",
		"直流运行电流过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"DCPower",
		"直流功率",
		"W",
		"直流功率",
		0,
		0,
		"直流功率过高",
		"直流功率过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ACPower",
		"交流功率",
		"W",
		"交流功率",
		0,
		0,
		"制冷量过高",
		"制冷量过低",
		0,
		0
	},
	{
		INTEGER,
		0,
		READONLY,
		"CoolingCapacity",
		"制冷量",
		"W",
		"制冷量",
		0,
		0,
		"制冷量过高",
		"制冷量过低",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"HighTemperatureAlarm",
		"高温报警",
		"",
		"高温报警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"InternalFanFailure",
		"内风机故障",
		"",
		"内风机故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OuterFanFailure",
		"外风机故障",
		"",
		"外风机故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CompressorFailure",
		"压缩机故障",
		"",
		"压缩机故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ReturnAirTemperatureSensorFailure",
		"柜内回风温度探头故障",
		"",
		"柜内回风温度探头故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"SystemHighPressureAlarm",
		"系统高压告警",
		"",
		"系统高压力告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"LowTemperatureAlarm",
		"低温告警",
		"",
		"低温告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DCOvervoltageAlarm",
		"直流过压告警",
		"",
		"直流过压告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"DCUndervoltageAlarm",
		"直流欠压告警",
		"",
		"直流欠压告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ACOvervoltageAlarm",
		"交流过压告警",
		"",
		"交流过压告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ACUndervoltageAlarm",
		"交流欠压告警",
		"",
		"交流欠压告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"ACPowerFailureAlarm",
		"交流掉电告警",
		"",
		"交流掉电告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"EvaporatorTemperatureSensorFailure",
		"蒸发器温度传感故障",
		"",
		"蒸发器温度传感故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"CondenserTemperatureSensorFailure",
		"冷凝器温度传感故障",
		"",
		"冷凝器温度传感故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AmbientTemperatureSensingFailure",
		"环境温度传感故障",
		"",
		"环境温度传感故障：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"EvaporatorFreezeAlarm",
		"蒸发器冻结报警",
		"",
		"蒸发器冻结报警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"FrequentHighPressureAlarm",
		"频繁高压力告警",
		"",
		"频繁高压力告警：0-正常，1-告警",
		0,
		0,
		"告警",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HeatingSensitivity",
		"制热精度",
		"°C",
		"制热精度",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"DehumidificationSetpoint",
		"除湿设定值",
		"%",
		"除湿设定值",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"DehumidificationSensitivity",
		"除湿精度",
		"%",
		"除湿精度",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HumidificationSetpoint",
		"加湿设定值",
		"%",
		"加湿设定值",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HumidificationSensitivity",
		"加湿精度",
		"%",
		"加湿精度",
		0,
		0,
		"",
		"",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit1EvaporatingPressure",
		"回路1蒸发器压力",
		"bar",
		"回路1蒸发器压力",
		0,
		0,
		"回路1蒸发器压力过高",
		"回路1蒸发器压力过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit2EvaporatingPressure",
		"回路2蒸发器压力",
		"bar",
		"回路2蒸发器压力",
		0,
		0,
		"回路2蒸发器压力过高",
		"回路2蒸发器压力过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit1SuctionTemperature",
		"回路1吸气温度",
		"℃",
		"回路1吸气温度",
		0,
		0,
		"回路1吸气温度过高",
		"回路1吸气温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit2SuctionTemperature",
		"回路2吸气温度",
		"℃",
		"回路2吸气温度",
		0,
		0,
		"回路2吸气温度过高",
		"回路2吸气温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit1EvaporatingTemperature",
		"回路1蒸发器温度",
		"℃",
		"回路1蒸发器温度",
		0,
		0,
		"回路1蒸发器温度过高",
		"回路1蒸发器温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit2EvaporatingTemperature",
		"回路2蒸发器温度",
		"℃",
		"回路2蒸发器温度",
		0,
		0,
		"回路2蒸发器温度过高",
		"回路2蒸发器温度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit1Superheat",
		"回路1过热度",
		"℃",
		"回路1过热度",
		0,
		0,
		"回路1过热度过高",
		"回路1过热度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"Circuit2Superheat",
		"回路2过热度",
		"℃",
		"回路2过热度",
		0,
		0,
		"回路2过热度过高",
		"回路2过热度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"ColdWaterValveRamp",
		"冷水阀开度",
		"%",
		"冷水阀开度",
		0,
		0,
		"冷水阀开度过高",
		"冷水阀开度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"HotWaterValveRamp",
		"热水阀开度",
		"%",
		"热水阀开度",
		0,
		0,
		"热水阀开度过高",
		"热水阀开度过低",
		0,
		0
	},
	{
		FLOAT,
		0,
		READONLY,
		"EvaporatingFanSpeed",
		"蒸发器风扇风速",
		"%",
		"蒸发器风扇风速",
		0,
		0,
		"蒸发器风扇风速过高",
		"蒸发器风扇风速过低",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"OnOffStatus",
		"开关机状态",
		"",
		"开关机状态：0-开机，1-关机",
		0,
		0,
		"关机",
		"",
		0,
		0
	},
	{
		OCTSTR,
		0,
		READONLY,
		"AlarmStatus",
		"报警状态",
		"",
		"报警状态：0-正常，1-存在报警",
		0,
		0,
		"报警",
		"",
		0,
		0
	}
};


/**********************************************************************************************************
* 函数名称： static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
* 函数说明： 生成获取传感器数据指令
* 输入参数： 指令索引，传感器地址，变量结构体指针,以及指令缓存区指针,指令长度
* 返回参数： 无
**********************************************************************************************************/
static void cmd_fun(short index, int addr, void *data, char *cmd, short *len)
{
	switch(index)
	{
		case 0:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x10;								
			cmd[3] = 0x00;
			cmd[4] = 0x00;	
			cmd[5] = 0x33;
			*len = CRC16_Padding(cmd, 6);
			break;
		case 1:
			cmd[0] = addr;
			cmd[1] = 0x03;
			cmd[2] = 0x03;								
			cmd[3] = 0x00;
			cmd[4] = 0x00;	
			cmd[5] = 0x11;
			*len = CRC16_Padding(cmd, 6);			
			break;
		default:
			break;
	}
}


/**********************************************************************************************************
* 函数名称： static int parse_fun(short index, int addr, void *data, char *buf, short len)
* 函数说明： 解析传感器响应的数据，并写入数据库
* 输入参数： 解析索引,传感器地址，变量结构体指针，以及响应数据缓存取指针，响应数据长度
* 返回参数： 返回解析结果，返回0成功，返回1失败
**********************************************************************************************************/
static int parse_fun(short index, int addr, void *data, char *buf, short len)
{
	union{
		short 			dat16;
      	unsigned char  	dat8[2];
    }DAT16_8;							//数据类型转换	
    union 		   					 
    {
		unsigned int	dat32;
		unsigned char   dat8[4];
    }DAT32_8;							//数据类型转换		
	Data_Struct 	*d = (Data_Struct*)data;
	
	if(buf!=NULL && buf[0]==addr && len>0 )
	{	
		if(CRC16_Check(buf,len))
		{
			switch(index)
			{
				case 0:
					if(buf[4]==0x01){
						d->EquipmentWorkStatus.value.str = "待机";
						Set_Var_Status(&d->EquipmentWorkStatus, Normal, NULL);						
					}
					else if(buf[4]==0x02){
						d->EquipmentWorkStatus.value.str = "运行";
						Set_Var_Status(&d->EquipmentWorkStatus, Normal, NULL);							
					}
					else if(buf[4]==0x03){
						d->EquipmentWorkStatus.value.str = "故障";
						Set_Var_Status(&d->EquipmentWorkStatus, Alarm, NULL);						
					}
					else{
						d->EquipmentWorkStatus.value.str = "未知";
						Set_Var_Status(&d->EquipmentWorkStatus, Unknown, NULL);							
					}
					
					if(buf[8]==0x01){
						d->IndoorFanStatus.value.str = "待机";
						Set_Var_Status(&d->IndoorFanStatus, Normal, NULL);						
					}
					else if(buf[8]==0x02){
						d->IndoorFanStatus.value.str = "运行";
						Set_Var_Status(&d->IndoorFanStatus, Normal, NULL);							
					}
					else if(buf[8]==0x03){
						d->IndoorFanStatus.value.str = "故障";
						Set_Var_Status(&d->IndoorFanStatus, Alarm, NULL);						
					}
					else{
						d->IndoorFanStatus.value.str = "未知";
						Set_Var_Status(&d->IndoorFanStatus, Unknown, NULL);							
					}
					
					if(buf[12]==0x01){
						d->OutdoorFanStatus.value.str = "待机";
						Set_Var_Status(&d->OutdoorFanStatus, Normal, NULL);						
					}
					else if(buf[12]==0x02){
						d->OutdoorFanStatus.value.str = "运行";
						Set_Var_Status(&d->OutdoorFanStatus, Normal, NULL);							
					}
					else if(buf[12]==0x03){
						d->OutdoorFanStatus.value.str = "故障";
						Set_Var_Status(&d->OutdoorFanStatus, Alarm, NULL);						
					}
					else{
						d->OutdoorFanStatus.value.str = "未知";
						Set_Var_Status(&d->OutdoorFanStatus, Unknown, NULL);							
					}					
					
					if(buf[16]==0x01){
						d->CompressorStatus.value.str = "待机";
						Set_Var_Status(&d->CompressorStatus, Normal, NULL);						
					}
					else if(buf[16]==0x02){
						d->CompressorStatus.value.str = "运行";
						Set_Var_Status(&d->CompressorStatus, Normal, NULL);							
					}
					else if(buf[16]==0x03){
						d->CompressorStatus.value.str = "故障";
						Set_Var_Status(&d->CompressorStatus, Alarm, NULL);						
					}
					else{
						d->CompressorStatus.value.str = "未知";
						Set_Var_Status(&d->CompressorStatus, Unknown, NULL);							
					}					
					
					DAT16_8.dat8[1] = buf[19];
					DAT16_8.dat8[0] = buf[20];
					d->ReturnAirTemperature.value.fnum = DAT16_8.dat16*0.1f;
					
					if(buf[24]==0x01){
						d->PumpStatus.value.str = "待机";
						Set_Var_Status(&d->PumpStatus, Normal, NULL);						
					}
					else if(buf[24]==0x02){
						d->PumpStatus.value.str = "运行";
						Set_Var_Status(&d->PumpStatus, Normal, NULL);							
					}
					else if(buf[24]==0x03){
						d->PumpStatus.value.str = "故障";
						Set_Var_Status(&d->PumpStatus, Alarm, NULL);						
					}
					else{
						d->PumpStatus.value.str = "未知";
						Set_Var_Status(&d->PumpStatus, Unknown, NULL);							
					}					
					
					DAT16_8.dat8[1] = buf[27];
					DAT16_8.dat8[0] = buf[28];
					d->OutsideTemperature.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[31];
					DAT16_8.dat8[0] = buf[32];
					d->CondenserTemperature.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[35];
					DAT16_8.dat8[0] = buf[36];
					d->EvaporatorTemperature.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[39];
					DAT16_8.dat8[0] = buf[40];
					d->InternalFanSpeed.value.inum = DAT16_8.dat16;
					DAT16_8.dat8[1] = buf[43];
					DAT16_8.dat8[0] = buf[44];
					d->OuterFanSpeed.value.inum = DAT16_8.dat16;
					DAT16_8.dat8[1] = buf[47];
					DAT16_8.dat8[0] = buf[48];
					d->ACInputVoltage.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[51];
					DAT16_8.dat8[0] = buf[52];
					d->DCInputVoltage.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[55];
					DAT16_8.dat8[0] = buf[56];
					d->ACRunningCurrent.value.fnum = DAT16_8.dat16*0.1f;					
					DAT32_8.dat8[3] = buf[59];
					DAT32_8.dat8[2] = buf[60];
					DAT32_8.dat8[1] = buf[61];
					DAT32_8.dat8[0] = buf[62];
					d->EquipmentRuntime.value.inum = DAT32_8.dat32;
					DAT32_8.dat8[3] = buf[67];
					DAT32_8.dat8[2] = buf[68];
					DAT32_8.dat8[1] = buf[69];
					DAT32_8.dat8[0] = buf[70];
					d->CompressorRuntime.value.inum = DAT32_8.dat32;
					DAT32_8.dat8[3] = buf[75];
					DAT32_8.dat8[2] = buf[76];
					DAT32_8.dat8[1] = buf[77];
					DAT32_8.dat8[0] = buf[78];
					d->InternalFanRuntime.value.inum = DAT32_8.dat32;
					DAT32_8.dat8[3] = buf[83];
					DAT32_8.dat8[2] = buf[84];
					DAT32_8.dat8[1] = buf[85];
					DAT32_8.dat8[0] = buf[86];
					d->CompressorOperationTimes.value.inum = DAT32_8.dat32;
					DAT16_8.dat8[1] = buf[91];
					DAT16_8.dat8[0] = buf[92];
					d->DCRunningCurrent.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[95];
					DAT16_8.dat8[0] = buf[96];
					d->DCPower.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[99];
					DAT16_8.dat8[0] = buf[100];
					d->ACPower.value.fnum = DAT16_8.dat16*0.1f;
					DAT16_8.dat8[1] = buf[103];
					DAT16_8.dat8[0] = buf[104];
					d->CoolingCapacity.value.inum = DAT16_8.dat16;
					break;
				case 1:
					d->HighTemperatureAlarm.value.str						= buf[4]==0x01?"告警":"正常";
					Set_Var_Status(&d->HighTemperatureAlarm, 				  buf[4]==0x01?Alarm:Normal, NULL);					
					d->InternalFanFailure.value.str							= buf[6]==0x01?"告警":"正常";
					Set_Var_Status(&d->InternalFanFailure, 					  buf[6]==0x01?Alarm:Normal, NULL);	
					d->OuterFanFailure.value.str							= buf[8]==0x01?"告警":"正常";
					Set_Var_Status(&d->OuterFanFailure, 					  buf[8]==0x01?Alarm:Normal, NULL);	
					d->CompressorFailure.value.str							= buf[10]==0x01?"告警":"正常";
					Set_Var_Status(&d->CompressorFailure, 					  buf[10]==0x01?Alarm:Normal, NULL);	
					d->ReturnAirTemperatureSensorFailure.value.str			= buf[12]==0x01?"告警":"正常";
					Set_Var_Status(&d->ReturnAirTemperatureSensorFailure, 	  buf[12]==0x01?Alarm:Normal, NULL);					
					d->SystemHighPressureAlarm.value.str					= buf[14]==0x01?"告警":"正常";
					Set_Var_Status(&d->SystemHighPressureAlarm, 			  buf[14]==0x01?Alarm:Normal, NULL);	
					d->LowTemperatureAlarm.value.str						= buf[16]==0x01?"告警":"正常";
					Set_Var_Status(&d->LowTemperatureAlarm, 				  buf[16]==0x01?Alarm:Normal, NULL);	
					d->DCOvervoltageAlarm.value.str							= buf[18]==0x01?"告警":"正常";
					Set_Var_Status(&d->DCOvervoltageAlarm, 					  buf[18]==0x01?Alarm:Normal, NULL);	
					d->DCUndervoltageAlarm.value.str						= buf[20]==0x01?"告警":"正常";
					Set_Var_Status(&d->DCUndervoltageAlarm, 				  buf[20]==0x01?Alarm:Normal, NULL);					
					d->ACOvervoltageAlarm.value.str							= buf[22]==0x01?"告警":"正常";
					Set_Var_Status(&d->ACOvervoltageAlarm, 					  buf[22]==0x01?Alarm:Normal, NULL);	
					d->ACUndervoltageAlarm.value.str						= buf[24]==0x01?"告警":"正常";
					Set_Var_Status(&d->ACUndervoltageAlarm, 				  buf[24]==0x01?Alarm:Normal, NULL);	
					d->ACPowerFailureAlarm.value.str						= buf[26]==0x01?"告警":"正常";
					Set_Var_Status(&d->ACPowerFailureAlarm, 				  buf[26]==0x01?Alarm:Normal, NULL);	
					d->EvaporatorTemperatureSensorFailure.value.str			= buf[28]==0x01?"告警":"正常";
					Set_Var_Status(&d->EvaporatorTemperatureSensorFailure, 	  buf[28]==0x01?Alarm:Normal, NULL);					
					d->CondenserTemperatureSensorFailure.value.str			= buf[30]==0x01?"告警":"正常";
					Set_Var_Status(&d->CondenserTemperatureSensorFailure, 	  buf[30]==0x01?Alarm:Normal, NULL);	
					d->AmbientTemperatureSensingFailure.value.str			= buf[32]==0x01?"告警":"正常";
					Set_Var_Status(&d->AmbientTemperatureSensingFailure, 	  buf[32]==0x01?Alarm:Normal, NULL);	
					d->EvaporatorFreezeAlarm.value.str						= buf[34]==0x01?"告警":"正常";
					Set_Var_Status(&d->EvaporatorFreezeAlarm, 				  buf[34]==0x01?Alarm:Normal, NULL);	
					d->FrequentHighPressureAlarm.value.str					= buf[36]==0x01?"告警":"正常";
					Set_Var_Status(&d->FrequentHighPressureAlarm, 			  buf[36]==0x01?Alarm:Normal, NULL);	
					break;
				default:
					break;
			}
			return 0;
		}
	}
	return 1;
}


/**********************************************************************************************************
* 函数名称： void jmkt_EC03U7_Registration(void)
* 函数说明： 精密空调驱动注册
* 输入参数： 无
* 返回参数： 无
**********************************************************************************************************/
void jmkt_EC03U7_Registration(void)
{
	DeviceRegWithResTimeout(
		"jmkt",													//设备类型
		"精密空调",												//设备名称（导航栏默认显示名称）
		"EC03U7",												//设备型号
		"适用于英维克EC系列交流空调，通讯协议为03U7-DC03-modbus。",//驱动描述
		var_attr,												//变量属性声明
		sizeof(Data_Struct),									//变量结构体空间大小
		cmd_fun,												//发送指令生成函数
		parse_fun,												//数据解析函数
		300														//设备响应超时时间
	);
		
#if 0
	#define CMD1 "\x01\x03\x10\x00\x00\x33\x01\x1F"
	#define RSP1 "\x01\x03\x66\x00\x02\xFF\xFF\x00\x02\xFF\xFF\x00\x01\xFF\xFF\x00\x01\xFF\xFF\x00\x9A\xFF\xFF\xFF\xFF\xFF\xFF\x7F\xFF\xFF\xFF\x00\x92\xFF\xFF\x00\x93\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x08\xF0\xFF\xFF\x00\xEA\xFF\xFF\x00\x00\xFF\xFF\x00\x00\x01\xD7\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\x01\xD7\xFF\xFF\xFF\xFF\x00\x00\x00\x00\xFF\xFF\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x00\x00\xFF\xFF\x01\x2C\xE2\x2C"	
	#define CMD2 "\x01\x03\x03\x00\x00\x11\x85\x82"
	#define RSP2 "\x01\x03\x22\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xB7\x43"			
		
	VirtualFrameRegistration(CMD1, sizeof(CMD1)-1, RSP1, sizeof(RSP1)-1);
	VirtualFrameRegistration(CMD2, sizeof(CMD2)-1, RSP2, sizeof(RSP2)-1);
#endif	
}

